home *** CD-ROM | disk | FTP | other *** search
- property firstTileChannel, firstTargetChannel, firstTileBmap, tilePointList, howManyCorrect, dragFlag, targetPointList, dragChan, selection, originalChannel, constrainChan, errorBuffer, enabled, tileList
- global gActorList, gHiddenActorList, gLevelObject, gUserObject, gGasGaugeObject, gMenuObject, gAwardsObject, gQTViewerObject, gVTLobject, gCDpath, gFileSep
-
- on birth me
- set enabled to 0
- set firstTileChannel to 16
- set firstTargetChannel to 4
- set constrainChan to 1
- set dragChan to 48
- set firstTileBmap to the number of cast "NumTimeline" + 1
- set tilePointList to [point(228, 43), point(328, 43), point(427, 43), point(228, 131), point(328, 131), point(427, 131), point(228, 222), point(328, 222), point(427, 222)]
- set targetPointList to [point(85, 314), point(143, 314), point(201, 314), point(259, 314), point(317, 314), point(375, 314), point(433, 314), point(491, 314), point(549, 314)]
- set dragFlag to 0
- newVTLgame(me)
- return me
- end
-
- on setup me
- add(gActorList, birth(script "Rollover Anim Button Class", "goMenu( gVTLgameObject, me )", 27, 27, 5, "RCA-07VO01", "RCA-07RO01"))
- add(gActorList, birth(script "Rollover Anim Button Class", "help( gVTLgameobject, me )", 28, 28, 11, EMPTY, "RCA-05RO02"))
- end
-
- on update me
- if not soundBusy(1) then
- puppetSound(0)
- end if
- set the locH of sprite dragChan to the mouseH
- set the locV of sprite dragChan to the mouseV
- puppetTempo(60)
- end
-
- on goVTLgame me
- clearAllActors()
- unpuppetAll()
- puppetPalette("VTLpal")
- go("Grass")
- go(the frame + 1)
- puppetPalette("VTLgamePal", 60)
- updateStage()
- puppetPalette(0)
- unLoadCast()
- set VTLgameFrame to "VTLg" & string(the level of gLevelObject)
- predrawVTLgameTiles(me)
- go(VTLgameFrame)
- end
-
- on saveVTLgame me
- set VTLgameString to string(enabled) & ","
- if enabled then
- set VTLgameString to VTLgameString & string(howManyCorrect) & ","
- repeat with tileObject in tileList
- set VTLgameString to VTLgameString & save(tileObject)
- end repeat
- end if
- return VTLgameString
- end
-
- on loadVTLgame me, index
- set enabled to value(item index of the dataString of gMenuObject)
- set index to index + 1
- if enabled = 1 then
- set howManyCorrect to value(item index of the dataString of gMenuObject)
- set index to index + 1
- set tileList to []
- repeat with whichTile = 1 to 9
- set randomPos to value(item index of the dataString of gMenuObject)
- set index to index + 1
- set placedPos to value(item index of the dataString of gMenuObject)
- set index to index + 1
- add(tileList, birth(script "VTLtile Parent", whichTile, randomPos, placedPos))
- end repeat
- end if
- return index
- end
-
- on newVTLgame me
- set scrambledList to shuffleList([1, 2, 3, 4, 5, 6, 7, 8, 9])
- set tileList to []
- repeat with tile = 1 to 9
- set scrambledPos to getPos(scrambledList, tile)
- add(tileList, birth(script "VTLtile Parent", tile, scrambledPos, 0))
- end repeat
- set errorBuffer to []
- set howManyCorrect to 0
- end
-
- on placeTile me
- set targetLocChan to firstTargetChannel + selection - 1
- set tileObject to getAt(tileList, selection)
- set originPoint to getAt(tilePointList, the scrambledPos of tileObject)
- if the level of gLevelObject = 3 then
- repeat with possibleTarget = firstTargetChannel to firstTargetChannel + 8
- if rollOver(possibleTarget) then
- set placed to 1
- exit repeat
- end if
- end repeat
- if placed = 1 then
- set newPos to possibleTarget - firstTargetChannel + 1
- if slotOccupied(me, newPos) then
- animateSprite(dragChan, originPoint, 5)
- turnDone(me)
- else
- animateSprite(dragChan, point(the locH of sprite possibleTarget, the locV of sprite possibleTarget), 1)
- set the timeLinePos of tileObject to newPos
- if possibleTarget = targetLocChan then
- set howManyCorrect to howManyCorrect + 1
- end if
- turnDone(me)
- checkForSuccess(me)
- end if
- else
- animateSprite(dragChan, originPoint, 5)
- turnDone(me)
- end if
- else
- if rollOver(targetLocChan) then
- set the timeLinePos of tileObject to targetLocChan - firstTargetChannel + 1
- set howManyCorrect to howManyCorrect + 1
- animateSprite(dragChan, point(the locH of sprite targetLocChan, the locV of sprite targetLocChan), 1)
- else
- animateSprite(dragChan, originPoint, 5)
- if the level of gLevelObject = 1 then
- add(errorBuffer, selection)
- if count(errorBuffer) = 3 then
- if (getAt(errorBuffer, 1) = getAt(errorBuffer, 2)) and (getAt(errorBuffer, 2) = getAt(errorBuffer, 3)) then
- sound playFile 1, gCDpath & "SOUND" & gFileSep & "GLOBAL" & gFileSep & "0820VO"
- repeat while soundBusy(1)
- end repeat
- puppetSound(0)
- set the timeLinePos of tileObject to targetLocChan - firstTargetChannel + 1
- set howManyCorrect to howManyCorrect + 1
- set errorBuffer to []
- animateSprite(dragChan, point(the locH of sprite targetLocChan, the locV of sprite targetLocChan), 3)
- else
- deleteAt(errorBuffer, 1)
- end if
- end if
- end if
- end if
- turnDone(me)
- checkForSuccess(me)
- end if
- end
-
- on slotOccupied me, newPos
- set occupiedFlag to 0
- repeat with tile in tileList
- if the timeLinePos of tile = newPos then
- set occupiedFlag to 1
- exit repeat
- end if
- end repeat
- return occupiedFlag
- end
-
- on doneButton me
- if buttonHandler() = 1 then
- startBuffering()
- puppetSound("DoneSound")
- updateStage()
- set wrongList to []
- repeat with tileObject in tileList
- if wrong(tileObject) then
- add(wrongList, tileObject)
- end if
- end repeat
- if count(wrongList) > 0 then
- set returnList to [0, 0, 0, 0, 0, 0, 0, 0, 0]
- repeat with wrongTile in wrongList
- setAt(returnList, the timeLinePos of wrongTile, wrongTile)
- end repeat
- repeat with tileObject in returnList
- if objectp(tileObject) then
- set the timeLinePos of tileObject to 0
- set channel to firstTileChannel + the scrambledPos of tileObject - 1
- set the castNum of sprite dragChan to the castNum of sprite channel
- set the locH of sprite dragChan to the locH of sprite channel
- set the locV of sprite dragChan to the locV of sprite channel
- set the locH of sprite channel to 1000
- updateStage()
- animateSprite(dragChan, getAt(tilePointList, the scrambledPos of tileObject), 3)
- set the castNum of sprite dragChan to the castNum of sprite channel
- set the locH of sprite channel to the locH of sprite dragChan
- set the locV of sprite channel to the locV of sprite dragChan
- set the locH of sprite dragChan to 1000
- updateStage()
- end if
- end repeat
- repeat while soundBusy(0)
- end repeat
- puppetSound(0)
- else
- checkForSuccess(me)
- end if
- flushBuffer()
- end if
- end
-
- on resetVTLgame me
- if buttonHandler() = 1 then
- startBuffering()
- puppetSound("RESETVTL")
- updateStage()
- set returnList to [0, 0, 0, 0, 0, 0, 0, 0, 0]
- repeat with tileObject in tileList
- set timeLinePos to the timeLinePos of tileObject
- if timeLinePos > 0 then
- setAt(returnList, timeLinePos, tileObject)
- end if
- end repeat
- repeat with tileObject in returnList
- if objectp(tileObject) then
- set channel to firstTileChannel + the scrambledPos of tileObject - 1
- set the castNum of sprite dragChan to the castNum of sprite channel
- set the locH of sprite dragChan to the locH of sprite channel
- set the locV of sprite dragChan to the locV of sprite channel
- set the locH of sprite channel to 1000
- updateStage()
- animateSprite(dragChan, getAt(tilePointList, the scrambledPos of tileObject), 3)
- set the castNum of sprite dragChan to the castNum of sprite channel
- set the locH of sprite channel to the locH of sprite dragChan
- set the locV of sprite channel to the locV of sprite dragChan
- set the locH of sprite dragChan to 1000
- updateStage()
- set the timeLinePos of tileObject to 0
- end if
- end repeat
- set errorBuffer to []
- set howManyCorrect to 0
- repeat while soundBusy(0)
- end repeat
- puppetSound(0)
- flushBuffer()
- end if
- end
-
- on turnDone me
- set the locH of sprite originalChannel to the locH of sprite dragChan
- set the locV of sprite originalChannel to the locV of sprite dragChan
- removeSprite(dragChan)
- updateStage()
- set the constraint of sprite dragChan to 0
- set dragFlag to 0
- deleteAt(gActorList, getPos(gActorList, me))
- showAllActors()
- end
-
- on checkForSuccess me
- if howManyCorrect = 9 then
- startBuffering()
- repeat while soundBusy(0)
- end repeat
- puppetSound(0)
- sound playFile 1, gCDpath & "SOUND" & gFileSep & "GLOBAL" & gFileSep & "0820C"
- giveAward(gAwardsObject, "VTL")
- newVTLgame(me)
- repeat while soundBusy(1)
- end repeat
- puppetSound(0)
- goToVideo(me)
- flushBuffer()
- end if
- end
-
- on predrawVTLgameTiles me
- repeat with tileNum = 1 to count(tileList)
- set tileObject to getAt(tileList, tileNum)
- if the timeLinePos of tileObject = 0 then
- set location to getAt(tilePointList, the scrambledPos of tileObject)
- else
- put the timeLinePos of tileObject
- set location to getAt(targetPointList, the timeLinePos of tileObject)
- end if
- set bmap to firstTileBmap + tileNum - 1
- set channel to firstTileChannel + the scrambledPos of tileObject - 1
- set the castNum of sprite channel to bmap
- set the locH of sprite channel to getAt(location, 1)
- set the locV of sprite channel to getAt(location, 2)
- set the ink of sprite channel to 36
- if channel = the channel of gGasGaugeObject then
- set the stretch of sprite the channel of gGasGaugeObject to 0
- set the ink of sprite the channel of gGasGaugeObject to 36
- set the foreColor of sprite the channel of gGasGaugeObject to 255
- end if
- puppetSprite(channel, 1)
- end repeat
- end
-
- on VTLgameTileHandler me
- set whichTile to value(the name of cast the castNum of sprite the clickOn)
- set tileObject to getAt(tileList, whichTile)
- if the timeLinePos of tileObject = 0 then
- puppetSound(getAt(the nameSoundList of gVTLobject, whichTile))
- set selection to whichTile
- set originalChannel to the clickOn
- set bitmap to the castNum of sprite the clickOn
- set the castNum of sprite dragChan to bitmap
- puppetSprite(dragChan, 1)
- puppetSprite(constrainChan, 1)
- set the locH of sprite dragChan to the locH of sprite the clickOn
- set the locV of sprite dragChan to the locV of sprite the clickOn
- set the locH of sprite the clickOn to 1000
- set the rect of sprite constrainChan to getBoundRect(bitmap, 0)
- updateStage()
- set the constraint of sprite dragChan to constrainChan
- animateSprite(dragChan, point(the mouseH, the mouseV), 1)
- set dragFlag to 1
- puppetTempo(60)
- add(gActorList, me)
- hideOtherActors(me)
- end if
- end
-
- on goToVideo me
- set videoName to "08.MOV"
- set the videoName of gQTViewerObject to videoName
- set paletteName to the name of cast (the number of cast videoName - 1)
- set the paletteName of gQTViewerObject to paletteName
- set the returnScript of gQTViewerObject to "returnFromQT( gVTLgameObject )"
- set errorBuffer to []
- clearAllActors()
- unpuppetAll()
- puppetPalette("VTLgamePal")
- go("Grass")
- go(the frame + 1)
- puppetPalette(paletteName, 60)
- updateStage()
- puppetPalette(0)
- unLoadCast()
- go("QT20")
- end
-
- on returnFromQT me
- prepareToLeave(gQTViewerObject)
- go("Grass")
- go(the frame + 1)
- unLoadCast()
- goLocationMap()
- end
-
- on goMenu me, buttonObject
- set errorBuffer to []
- clearAllActors()
- unpuppetAll()
- if objectp(buttonObject) then
- makeButtonJump(buttonObject)
- end if
- puppetPalette("VTLgamePal")
- go("Grass")
- go(the frame + 1)
- unLoadCast()
- goLocationMap()
- end
-
- on help me, buttonObject
- set whichHelp to "VTLgame" & string(the level of gLevelObject)
- birth(script "Help Parent", buttonObject, whichHelp)
- end
-